
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[spSchedule_DeleteSchedule]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
	DROP PROCEDURE [dbo].[spSchedule_DeleteSchedule]
GO


GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		Eric Liew
-- Create date: 6/2/2009
-- Description:	Delete Plate
-- =============================================
CREATE PROCEDURE [dbo].[spSchedule_DeleteSchedule]
(
		@scheduleDate VARCHAR(50),
		@shiftId	INT
)
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;
	DECLARE @Scheduleid INT
	
	SELECT @Scheduleid = Scheduleid  FROM Schedule 
	WHERE Schedule.ScheduleDate = @scheduleDate AND
	      Schedule.ShiftId = @shiftId 
	      
	DELETE Schedule 
	WHERE Schedule.ScheduleDate = @scheduleDate AND
	      Schedule.ShiftId = @shiftId
	      
	Delete ScheduleDriverTaxi
    Where ScheduleDriverTaxi.ScheduleId = @Scheduleid
	      
	SELECT 1
	    
END
GO
